// dofile of "Does Leadership Gender Representativeness Improve Policy Outcomes? Evidence from Local Governments in China"

***************
* Figure 1  *
***************

**Summarized from the BPCS run, author's own. 

***************
* Table 1  *
***************

use BPCS_data.dta,clear

asdoc sum satis percep score rank number gender middlegender city population logeco street1 age edu1 edu2 edu3 edu4 beijing exp, dec(2) replace

***************
* Table 2  *
***************

use BPCS_data.dta,clear

eststo clear
eststo: quietly xtreg score gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg score middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg score gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg rank gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg rank middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg rank gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg satis gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg satis middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg satis gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg percep gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg percep middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg percep gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg number gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg number middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg number gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
esttab using Table2randomeffect.rtf,replace label b(%9.3f) t(%7.3f) nocon se r2 title({\b Table 2.} {\i Random-effect  regression estimates}) /// 
mtitles("score" "score" "score" "rank" "rank" "rank" "satis" "satis" "satis" "percep" "percep" "percep" "number" "number" "number") compress nogap starlevels(* 0.10 ** 0.05 *** 0.01) 

***************
* Table 3  *
***************

**Summarized from the Table 2.

*********************************************
**************** Appendix ***************
*********************************************

***************
* Figure S1  *
***************

use BPCS_data.dta,clear

local sch2 scheme(s1mono)  //黑白
twoway (connected score month, msymbol(o) color(gs5)) , ytitle(score) by(ID) xsize(3) ysize(2) xlabel(minmax) legend (region(fcolor(none) ///
lpattern(blank)) textwidth(25) cols(3) pos(0))scheme(s1mono)

***************
* Figure S2  *
***************

use BPCS_data.dta,clear

local sch2 scheme(s1mono)  //黑白
twoway (connected rank month, msymbol(o) color(gs5)) , ytitle(rank) by(ID) xsize(3) ysize(2) xlabel(minmax) legend (region(fcolor(none) ///
lpattern(blank)) textwidth(25) cols(3) pos(0))scheme(s1mono)

***************
* Figure S3  *
***************

use BPCS_data.dta,clear

local sch2 scheme(s1mono)  //黑白
twoway (connected satis month, msymbol(o) color(gs5)) , ytitle(satisfaction) by(ID) xsize(3) ysize(2) xlabel(minmax) legend (region(fcolor(none) ///
lpattern(blank)) textwidth(25) cols(3) pos(0))scheme(s1mono)

***************
* Figure S4  *
***************

use BPCS_data.dta,clear

local sch2 scheme(s1mono)  //黑白
twoway (connected percep month, msymbol(o) color(gs5)) , ytitle(perception) by(ID) xsize(3) ysize(2) xlabel(minmax) legend (region(fcolor(none) ///
lpattern(blank)) textwidth(25) cols(3) pos(0))scheme(s1mono)

***************
* Figure S5  *
***************

use BPCS_data.dta,clear

local sch2 scheme(s1mono)  //黑白
twoway (connected number month, msymbol(o) color(gs5)) , ytitle(Number of complaints) by(ID) xsize(3) ysize(2) xlabel(minmax) legend (region(fcolor(none) ///
lpattern(blank)) textwidth(25) cols(3) pos(0))scheme(s1mono)

***************
* Figure S6  *
***************

***depicted in excel

***************
* Table S1  *
***************

use BPCS_data.dta,clear

logout, dec(2) save("TableS1_corr") excel replace: ///
        pwcorr score rank satis percep number gender middlegender city population logeco street1 age edu2 edu3 edu4 beijing exp,star(0.01)

collin gender middlegender city population logeco street1 age edu2 edu3 edu4 beijing exp

gen edu5=edu3
replace edu5=1 if edu2==1
	
logout, dec(2) save("TableS1_corr") excel replace: ///
        pwcorr score rank satis percep number gender middlegender city population logeco street1 age edu4 edu5 beijing exp,star(0.01)

collin gender middlegender city population logeco street1 age edu4 edu5 beijing exp

***************
* Table S2  *
***************

use BPCS_data.dta,clear

eststo clear
eststo: quietly xtgls score gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls score middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls score gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls rank gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls rank middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls rank gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls satis gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls satis middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls satis gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls percep gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls percep middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls percep gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls number gender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls number middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
eststo: quietly xtgls number gender middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month, panels(hetero) corr(ar1) force
esttab using TableS2gls.rtf,replace label b(%9.3f) t(%7.3f) nocon scalar(chi2) se title({\b Table S2.} {\i gls regression estimates}) /// 
mtitles("score" "score" "score" "rank" "rank" "rank" "satis" "satis" "satis" "percep" "percep" "percep" "number" "number" "number") compress nogap starlevels(* 0.10 ** 0.05 *** 0.01) 

***************
* Table S3  *
***************

use BPCS_data.dta,clear

collapse score rank satis percep number gender middlegender city population logeco street1 age edu4 edu5 jixu beijing exp dedu district1, by(ID)

eststo clear
eststo: quietly reg score gender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg score middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg score gender middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg rank gender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg rank middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg rank gender middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg satis gender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg satis middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg satis gender middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg percep gender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg percep middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg percep gender middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg number gender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg number middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
eststo: quietly reg number gender middlegender city population logeco street1 age edu4 edu5 beijing exp,vce(robust)
esttab using TableS3ols.rtf,replace label b(%9.3f) t(%7.3f) nocon se r2 title({\b Table S3.} {\i ols  regression estimates}) /// 
mtitles("score" "score" "score" "rank" "rank" "rank" "satis" "satis" "satis" "percep" "percep" "percep" "number" "number" "number") compress nogap starlevels(* 0.10 ** 0.05 *** 0.01) 

***************
* Table S4  *
***************

use BPCS_data.dta,clear

eststo clear
eststo: quietly xtreg score i.gender##c.middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg rank i.gender##c.middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg satis i.gender##c.middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
eststo: quietly xtreg percep i.gender##c.middlegender city population logeco street1 age edu4 edu5 beijing exp i.district1 i.month,vce (cluster ID) re
esttab using TableS5moderating.rtf,replace label b(%9.3f) t(%7.3f) nocon se r2 title({\b Table S5.} {\i moderating  regression estimates}) /// 
mtitles("score" "rank" "satis" "percep") compress nogap starlevels(* 0.10 ** 0.05 *** 0.01) 
